<?php
namespace app\index\common;

class common{
    /**
     * 关联数组判段值是否为空
     */
    public function  isNull($data){
        $len=count($data);
        if($len){
            foreach ($data as $k => $v){
                if($v) return;
            }
            return "数据不能为空";
        }
    }

    /**
     * 弹出信息
     */
    public static function showMsg($msg){
        echo  "<script language=\"javascript\">alert('.$msg.');window.history.go(-1)</script>";

    }

    /**
     * 订单随机数
     */

    public function createdNumber()
    {
        $yCode = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
        ];
        $nowYear = 2018;
        if ((intval(date('Y')) - $nowYear) > 25) {

            $nowYear = intval(date('Y'));
        }
        $OrderNumber = $yCode[intval(date('Y')) - $nowYear]
            . strtoupper(dechex(date('m')))
            . date('d') . substr(time(), -5)
            . substr(microtime(), 2, 5)
            . sprintf('%02d', rand(0, 99));

        return $OrderNumber;
    }


    /**
     * dd函数大体同laravel
     */
    public function dd($data){
        dump($data);exit();
    }
}